home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 031a / wb613_01.zip / SAMPLE.C < prev    next >
C/C++ Source or Header  |  1991-10-07  |  7KB  |  144 lines

  1. /*
  2. ** Example Data Entry program
  3. */
  4.  
  5. #include "winboss.h"                    /* ALWAYS */
  6.  
  7. main()                                  /* simple test pgm */
  8. {
  9. WIFORM frm;                             /* our form */
  10. WINDOWPTR w1;                           /* window to use */
  11. int month, day, year;                   /* date stuff */
  12. int hrs, mins, secs;                    /* time stuff */
  13. int ss1, ss2, ss3;                      /* social security no(s) */
  14. float fval;                             /* float stuff */
  15. int ac, nnx, num;                       /* phone stuff */
  16. int ival;                               /* int stuff */
  17. unsigned uval;                          /* unsigned stuff */
  18. long lval;                              /* long stuff */
  19. int bval;                               /* bool stuff */
  20. unsigned long ulval;                    /* unsigned long stuff */
  21. double dval;                            /* double stuff <grin (oreo)> */
  22. char *hmsg, *emsg;                      /* help and error messages */
  23. char dbuff[10];                         /* date buffer */
  24. char tbuff[10];                         /* time buffer */
  25. char txb1[120], txb2[120], txb3[120];   /* text buffers */
  26. char fbuf[30];                          /* float buffer */
  27. char pbuff[30];                         /* phone buffer */
  28. char ibuff[30];                         /* int buffer */
  29. char lbf[30];                           /* long buffer */
  30. char bool[30];                          /* bool buffer */
  31. char ubf[30];                           /* unsigned buffer */
  32. char pwbuf[120];                        /* password buffer */
  33. char ulbf[30];                          /* unsigned long buffer */
  34. char dbl[30];                           /* double buffer <grin (devices)> */
  35. char *tb[2];                            /* table of pointers */
  36. char ssn[12];                           /* social security # */
  37.  
  38. unsigned atrib;                         /* attribute */
  39.  
  40.   atrib = (BLUE<<4 | WHITE);            /* simple attributes */
  41.  
  42.   wn_init();
  43.   w1=wn_open(0,5,10,38,16,NVIDEO,NVIDEO);/* open a window */
  44.   if(!w1) exit(0);                      /* die if error */
  45.  
  46.                                         /* init edit buffers */
  47.   ibuff[0] = NUL;                       /* integer */
  48.   dbuff[0] = NUL;                       /* date */
  49.   tbuff[0] = NUL;                       /* time */
  50.   txb1[0] = NUL;                        /* text field # 1 */
  51.   txb2[0] = NUL;                        /* text field # 2 */
  52.   txb3[0] = NUL;                        /* text field # 3 */
  53.   fbuf[0] = NUL;                        /* float */
  54.   pbuff[0] = NUL;                       /* phone */
  55.   ubf[0] = NUL;                         /* unsigned */
  56.   lbf[0] = NUL;                         /* long */
  57.   bool[0] = NUL;                        /* logical */
  58.   pwbuf[0] = NUL;                       /* password */
  59.   ulbf[0] = NUL;                        /* unsigned long */
  60.   dbl[0] = NUL;                         /* double */
  61.   ssn[0] = NUL;                         /* social securty # */
  62.   tb[0] = txb1;                         /* set up arrary of ptrs */
  63.   tb[1] = txb2;                         /* for multi-line input */
  64.  
  65.   hmsg = "Sample Help Message";         /* help & error messages */
  66.   emsg = "Sample Error Message";        /* in actual practice, each */
  67.                                         /* field should have its own */
  68.  
  69.                                         /* IMMEDIATE XEQ first */
  70.  
  71.   wn_dtext(XEQ,NFRM,NFLD,w1,0,1,"DTEXT display text line 1!!"); 
  72.   wn_guint(XEQ,NFRM,NFLD,w1,1,1,"Uint: ", atrib, '_',&uval,6,0,10000,ubf,hmsg,emsg);
  73.   wn_gdate(XEQ,NFRM,NFLD,w1,2,1,"Date: ", atrib,'_',&month,&day,&year,dbuff,hmsg,emsg);
  74.   wn_gtime(XEQ,NFRM,NFLD,w1,3,1,"Time: ", atrib,'_',&hrs,&mins,&secs,tbuff,hmsg,emsg);
  75.   wn_gmltext(XEQ,NFRM,NFLD,w1,4,1,"Text: ", atrib,'_',30,2,tb,hmsg,emsg);
  76.   wn_gtext(XEQ,NFRM,NFLD,w1,6,1,"Text: ", atrib,'_',30,txb3,hmsg,emsg);
  77.   wn_gfloat(XEQ,NFRM,NFLD,w1,7,1,"Float: ", atrib, '_',&fval,8,2,-10000.0,10000.0,fbuf,hmsg,emsg);
  78.   wn_gphone(XEQ,NFRM,NFLD,w1,8,1,"Phone: ", atrib, '_',&ac,&nnx,&num,pbuff,hmsg,emsg); 
  79.   wn_glong(XEQ,NFRM,NFLD,w1,9,1,"Long: ",   atrib, '_',&lval,6,-10000l,10000l,lbf,hmsg,emsg);
  80.   wn_gbool(XEQ,NFRM,NFLD,w1,10,1,"BOOL: ",  atrib, '_',&bval,bool,hmsg,emsg);
  81.   wn_gint(XEQ,NFRM,NFLD,w1,11,1,"Int: ",    atrib, '_',&ival,6,-10000,10000,ibuff,hmsg,emsg);
  82.   wn_gpword(XEQ,NFRM,NFLD,w1,12,1,"PWD:  ", atrib, '_',30,pwbuf,hmsg,emsg);
  83.   wn_gulong(XEQ,NFRM,NFLD,w1,13,1,"Ulong:", atrib, '_',&ulval,10,0l,0xf5000000l,ulbf,hmsg,emsg);
  84.   wn_gdouble(XEQ,NFRM,NFLD,w1,14,1,"Doubl: ", atrib, '_',&dval,8,2,-10000.0,10000.0,dbl,hmsg,emsg);
  85.   wn_gssn(XEQ,NFRM,NFLD,w1,15,1,"SSN:  ",atrib,'_',&ss1,&ss2,&ss3,ssn,hmsg,emsg);
  86.  
  87.  
  88.   v_wtty(7);                            /* ding the bell and */
  89.   v_getch();                            /* wait for a key to be struck */
  90.   wn_clr(w1);                           /* clear the window */
  91.                                         /* open form */
  92.   frm = wn_frmopn(17);                  /* 15 fields */
  93.   if(!frm) exit(0);                     /* die if error */
  94.  
  95. /*
  96.    SETup the form... note that since the edit buffers were not reset, 
  97.    the fields will be pre filled!! 
  98. */
  99.  
  100.   wn_dtext(SET,frm,0,w1,0,1,"DTEXT display text line 1!!"); 
  101.   wn_guint(SET,frm,1,w1,1,1,"Uint: ", atrib, '_',&uval,6,0,10000,ubf,hmsg,emsg);
  102.   wn_gdate(SET,frm,2,w1,2,1,"Date: ", atrib,'_',&month,&day,&year,dbuff,hmsg,emsg);
  103.   wn_gtime(SET,frm,3,w1,3,1,"Time: ", atrib,'_',&hrs,&mins,&secs,tbuff,hmsg,emsg);
  104.   wn_gmltext(SET,frm,4,w1,4,1,"Text: ", atrib,'_',30,2,tb,hmsg,emsg);
  105.   wn_gtext(SET,frm,5,w1,6,1,"Text: ", atrib,'_',30,txb3,hmsg,emsg);
  106.   wn_gfloat(SET,frm,6,w1,7,1,"Float: ", atrib, '_',&fval,8,2,-10000.0,10000.0,fbuf,hmsg,emsg);
  107.   wn_gphone(SET,frm,7,w1,8,1,"Phone: ", atrib, '_',&ac,&nnx,&num,pbuff,hmsg,emsg); 
  108.   wn_glong(SET,frm,8,w1,9,1,"Long: ",   atrib, '_',&lval,6,-10000l,10000l,lbf,hmsg,emsg);
  109.   wn_gbool(SET,frm,9,w1,10,1,"BOOL: ", atrib, '_',&bval,bool,hmsg,emsg);
  110.   wn_gint(SET,frm,10,w1,11,1,"Int: ",   atrib, '_',&ival,6,-10000,10000,ibuff,hmsg,emsg);
  111.   wn_gpword(SET,frm,11,w1,12,1,"PWD:  ", atrib, '_',30,pwbuf,hmsg,emsg);
  112.   wn_gulong(SET,frm,12,w1,13,1,"Ulong:", atrib, '_',&ulval,10,0l,0xf5000000l,ulbf,hmsg,emsg);
  113.   wn_gdouble(SET,frm,13,w1,14,1,"Doubl: ", atrib, '_',&dval,8,2,-10000.0,10000.0,dbl,hmsg,emsg);
  114.   wn_gssn(SET,frm,14,w1,15,1,"SSN:  ",atrib,'_',&ss1,&ss2,&ss3,ssn,hmsg,emsg);
  115.  
  116.   if(wn_frmget(frm) == ESC_CODE)        /* read the form */
  117.     v_wtty(7);                          /* beep if escape was pressed */
  118.  
  119.   wn_frmcls(frm);                       /* close the form */
  120.   wn_close(w1);                         /* then the window */
  121.  
  122.   wn_exit();
  123.                                         
  124.                                         /* Display results */
  125.   printf("DATE   %d/%d/%d\n", month,day,year);
  126.   printf("TIME   %02d:%02d:%02d\n",hrs,mins,secs);
  127.   printf("TEXT   %s\n",txb1);
  128.   printf("TEXT   %s\n",txb2);
  129.   printf("TEXT   %s\n",txb3);
  130.   printf("INT    %d\n",ival); 
  131.   printf("UINT   %u\n",uval);
  132.   printf("FLOAT  %f\n",fval);
  133.   printf("PHONE  %d-%d-%d\n",ac,nnx,num);
  134.   printf("LONG   %ld\n",lval);
  135.   printf("BOOL   %d\n", bval);
  136.   printf("PWORD  %s\n",pwbuf);
  137.   printf("ULONG  %lu\n",ulval);
  138.   printf("DBL    %lf\n",dval);
  139.   printf("SSN    %03d-%02d-%03d\n",ss1,ss2,ss3);
  140.  
  141.   exit(0);
  142. }
  143.  
  144.